<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/common.jsp" %>
<%
    List<Option> custTypeOptions=optionService.getOptions2("4028aa303c89a724013c89b1e7d2001f",null);
    List<String> custTypeName = new ArrayList<String>();
    StringBuffer sb = new StringBuffer();
    int i=0;

    for(Option option:custTypeOptions){
            String type =  "{\n" +
                                "text:'"+option.getObjname()+"',\n" +
                                "hrefTarget:'rightframe',\n" +
                                "href:'/reportdata.do?action=search&isnew=1&reportid=402881ef3cfb57d2013cfb81789a007f&conut_customerinfo_crmtype_value="+option.getId()+"',\n" +
                                "leaf:true\n" +
                            "}";
            if(i==0){
                sb = sb.append(type);
            }else{
                sb = sb.append(","+type);
            }
            i++;
    }
    String customerType = sb.toString();
    OrgService orgService=Env.getBean("orgService");
    StringBuffer orgsStringBuffer = new StringBuffer();
   // List<Org> orgs = orgService.find("from Org where objname like '%大区'");
    List<Org> orgs=orgService.find("from Org where objname like ?",new Object[]{"%大区"});
    if(orgs.size()>0){
        int j=0;
        for(Org obj : orgs){
            String str = "{\n" +
                    "text:'"+obj.getObjname()+"',\n" +
                    "hrefTarget:'rightframe',\n" +
                    "href:'/reportdata.do?action=search&isnew=1&reportid=402881ef3cfb57d2013cfb81789a007f&conut_customerinfo_dqid_value="+obj.getId()+"',\n" +
                    "leaf:true\n" +
                    "}";
            if(j==0){
                orgsStringBuffer = orgsStringBuffer.append(str);
            }else{
                orgsStringBuffer = orgsStringBuffer.append(","+str);
            }
            j++;
        }
    }
    String daquPanel = orgsStringBuffer.toString();

    String currUser = Env.getRemoteUser().getCurrentuserid();//当前用户的ID
%>
<html>
<head>
    <%@ include file="/common/head.jsp" %>
    <title>customerInfo.jsp</title>
    <script type="text/javascript">
        var store;
        Ext.onReady(function () {
            //var mycrm_url='/reportdata.do?action=search&isnew=1&reportid=402881ef3cfb57d2013cfb81789a007f&conut_customerinfo_managerid_value='+'<%=currUser%>';
			var mycrm_url='/reportdata.do?action=search&isnew=1&reportid=402881ef3cfb57d2013cfb81789a007f';
            var treepanel_daqufenlei = new Ext.tree.TreePanel({
                animate:false,
                title:'大区分组',
                useArrows :true,
                containerScroll: true,
                rootVisible:false,
                collapsible:true,//是否收缩,右上角的下拉框
                autoScroll:true,//高度超出范围是否显示滚动条
                frame : true,// 美化界面
                lines:true,//横竖线
                loader:new Ext.tree.TreeLoader(),
                root:new Ext.tree.AsyncTreeNode({//结点
                    id:'root',
                    text:'大区分组',
                    allowDrag:false,
                    allowDrop:false,
                    expanded:true,//是否展开
                    leaf:false,//是否为叶子结点,如果是叶子结点，则图标前面不会有+号，如果不会则有+号
            children:[
                        <%=daquPanel%>
                    ]
                })
            });
            var treepanel_customerType = new Ext.tree.TreePanel({
                animate:false,
                title:'客户类型',
                useArrows :true,
                collapsible:true,//是否收缩,右上角的下拉框
                autoScroll:true,//高度超出范围是否显示滚动条
                containerScroll: true,
                rootVisible:false,
                frame : true,// 美化界面
                lines:true,//横竖线
                loader:new Ext.tree.TreeLoader(),
                root:new Ext.tree.AsyncTreeNode({//结点
                    id:'root',
                    text:'类型分组',
                    expanded:true,//是否展开
                    leaf:false,//是否为叶子结点,如果是叶子结点，则图标前面不会有+号，如果不会则有+号
                    children:[
                        <%=customerType%>
                    ]
                })
            });

            var treepanel_xiashu = new Ext.tree.TreePanel({
                animate:false,
                title:'快速查找',
                useArrows :true,
                containerScroll: true,
                rootVisible:false,
                collapsible:true,//是否收缩,右上角的下拉框
                autoScroll:true,//高度超出范围是否显示滚动条
                frame : true,// 美化界面
                lines:true,//横竖线
                loader:new Ext.tree.TreeLoader(),
                root:new Ext.tree.AsyncTreeNode({//结点
                    id:'root',
                    allowDrag:false,
                    allowDrop:false,
                    expanded:true,//是否展开
                    leaf:false,//是否为叶子结点,如果是叶子结点，则图标前面不会有+号，如果不会则有+号
                    children:[{
                        text:'我的客户',
                        hrefTarget:'rightframe',                        href:'/reportdata.do?action=search&isnew=1&reportid=402881ef3cfb57d2013cfb81789a007f&conut_customerinfo_managerid_value='+'<%=currUser%>',
                        leaf:true
                    },{
                        text:'最近联系',
                        hrefTarget:'rightframe',                      href:'/reportdata.do?action=search&reportid=402881e43d1436e5013d155f4b6200cd&conut_contactlist_lxer_value='+'<%=currUser%>',
                        leaf:true
                    },{
                        text:'我的收藏',
                        hrefTarget:'rightframe',                      href:'/favorite/favoritelist.jsp?dowid=402881e43cfa96bb013cfb3b388b00ae',
                        leaf:true
                    },
							{
                        text:'所有下属的客户',
                        hrefTarget:'rightframe',
                        href:'subcustomerinfo.jsp?allsub=1',
                        leaf:true
                    }]
                })

            });

            var treepanel_nocontact = new Ext.tree.TreePanel({
                animate:false,
                title:'未联系日期时间段',
                useArrows :true,
                collapsible:true,//是否收缩,右上角的下拉框
                autoScroll:true,//高度超出范围是否显示滚动条
                containerScroll: true,
                rootVisible:false,
                frame : true,// 美化界面
                lines:true,//横竖线
                loader:new Ext.tree.TreeLoader(),
                root:new Ext.tree.AsyncTreeNode({//结点
                    id:'root',
                    text:'类型分组',
                    expanded:true,//是否展开
                    leaf:false,//是否为叶子结点,如果是叶子结点，则图标前面不会有+号，如果不会则有+号
                    children:[{
                            text:'三天没联系',
                            hrefTarget:'rightframe',
                            href:'/reportdata.do?action=search&reportid=402881e4407a7cbe014080c91c4a16ef&isshow=0',
                            leaf:true
                        },{
                            text:'一周没联系',
                            hrefTarget:'rightframe',
                            href:'/reportdata.do?action=search&reportid=402881e4407a7cbe014080dc36791c46&isshow=0',
                            leaf:true
                        },{
                            text:'两周没联系',
                            hrefTarget:'rightframe',
                            href:'/reportdata.do?action=search&reportid=402881e4407a7cbe014080dd49db1c57&isshow=0',
                            leaf:true
                        },{
                            text:'一个月没联系',
                            hrefTarget:'rightframe',
                            href:'/reportdata.do?action=search&reportid=402881e4407a7cbe014080de47e41ca6&isshow=0',
                            leaf:true
                    }]
                })
            });


            var accordion = new Ext.Panel({
                title: '客户分类',
                layout: 'accordion',
                region: 'west',
                width: 250,
                collapsible:true,
                collapseMode:"mini",
                layoutConfig: {
                    titleCollapse: true,
                    animate: false,
                    activeOnTop: false
                },
                items: [
                        treepanel_xiashu,
                        treepanel_daqufenlei,
                        treepanel_customerType,
                        treepanel_nocontact
                    ]
            });
            var viewport = new Ext.Viewport({
                layout: 'border',
                items: [
                    accordion,
                    {
                        region: 'center',
                        xtype: 'iframepanel',
                        frameConfig: {
                            id: 'rightframe',
                            name: 'rightframe',
                            frameborder: 0,
                            eventsFollowFrameLinks: false
                        },
                        autoScroll: true
                    }
                ]
            });
            rightframe.location = mycrm_url;
        });
    </script>
</head>
<body>
</body>
</html>
